<!DOCTYPE HTML>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:include="include :: head('菜单编辑')"></head>
<body style="background-color:#fff">
<div class="yadmin-body animated fadeIn">
    <div class="layui-form layui-form-pane">
        <input type="hidden" name="confId" th:value="${conf?.confId}" />
        <div class="layui-form-item">
            <label for="name" class="layui-form-label"><span class="yadmin-red">*</span>名称</label>
            <div class="layui-input-block">
                <input type="text" id="name" placeholder="请输入名称" name="name" th:value="${conf?.name}" lay-verify="required" lay-vertype="tips" autocomplete="off" class="layui-input" />
            </div>
        </div>
        <div class="layui-form-item">
            <label for="value" class="layui-form-label"><span class="yadmin-red">*</span>类型</label>
            <div class="layui-input-block">
                <select id="sex" name="sex" class="layui-input" lay-verify="required" lay-vertype="tips" th:with="type=${@dict.getType('SYSTEM_TYPE')}">
                    <option th:each="dict : ${type}" th:text="${dict.name}" th:value="${dict.code}" th:selected="${conf?.type eq dict.code}"></option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="key" class="layui-form-label"><span class="yadmin-red">*</span>键名</label>
            <div class="layui-input-block">
                <input type="text" id="key" placeholder="请输入键名" name="key" th:value="${conf?.key}" lay-verify="required" lay-vertype="tips" autocomplete="off" class="layui-input" />
            </div>
        </div>
        <div class="layui-form-item">
            <label for="value" class="layui-form-label"><span class="yadmin-red">*</span>键值</label>
            <div class="layui-input-block">
                <input type="text" id="value" placeholder="请输入键值" name="value" th:value="${conf?.value}" lay-verify="required" lay-vertype="tips" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="code" class="layui-form-label">编码</label>
            <div class="layui-input-block">
                <input type="text" id="code" placeholder="请输入编码" name="code" th:value="${conf?.code}" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="sort" class="layui-form-label">排序</label>
            <div class="layui-input-block">
                <input type="text" id="sort" placeholder="请输入排序" name="sort" th:value="${conf?.sort}" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block" style="margin-left:0;text-align:center;">
                <button class="layui-btn layui-btn-normal btn-w100" lay-submit="" lay-filter="submit-form">保存</button>
            </div>
        </div>
    </div>
</div>
<script>
layui.use(['form', 'layer'], function () {
    var form = layui.form, $ = layui.$;
    
    form.on('submit(submit-form)', function (obj) {
        $.ajax({
            type: "POST",
            url: '/conf/save',
            data: obj.field,
            dataType: 'json',
            cache: false,
            success: function (data) {
                let index = parent.layer.getFrameIndex(window.name);
                parent.location.replace(parent.location.href)
                parent.layer.close(index);
            },
            error: function (event) {
                errors(event);
            }
        });
    });
});
</script>
</body>
</html>
